<template>
<div class="personal">
    <router-link to="/edit_profile">
        <div class="profile">
            <!-- <img  src="http://img1.imgtn.bdimg.com/it/u=3757784226,1202878475&fm=26&gp=0.jpg" alt /> -->
            <img  :src="user.head_img | joinPath" alt />
            <div class="profile-center">
                <div class="name">
                    <span class="iconfont" 
                    :class="{ iconxingbienan: user.gender==1, 
                    iconxingbienv: user.gender==0 }"></span>
                    {{user.nickname}}
                </div>
                <div class="time">{{ new Date(user.create_date).toLocaleDateString()  }}</div>
            </div>
            <span class="iconfont iconjiantou1"></span>
        </div>
    </router-link>
    <div class="content">
        <van-cell title="我的关注" is-link value="关注的用户" />
        <van-cell title="我的跟帖" is-link value="跟帖/回复" />
        <van-cell title="我的收藏" is-link value="文章/视频" />
        <van-cell title="设置" is-link />
    </div>
    <van-button block round color="#eb6112" @click="outinFn">退出</van-button>
</div>
</template>

<script>
import { userDetail } from "@/api/user.js"
export default {
  data(){
    return {
      user: {}
    }
  },
  created(){
    let id = localStorage.getItem("72-user-id");
    userDetail(id).then(res=>{
      console.log(res);
      if(res.data.message === "获取成功"){
        this.user = res.data.data;
      }
    })
  },
  methods:{
    // 退出
    outinFn(){
      localStorage.removeItem("72-token");
      localStorage.removeItem("72-user-id");
      this.$router.push({
        path: "/login"
      })
    }
  }
}
</script>

<style lang="less" scoped>
// 组件库中的组件名就是该组件跟标签类名
// 所以我们设置样式的时候直接拿这个类名即可
.van-cell{
    background-color: #eee;
    border-bottom: 2px solid #ddd;
}
.van-button{
    width: 90%;
    margin: 0 auto;
    margin-top: 20px;
}
.personal{
    width: 100vw;
    height: 100vh;
    background-color: #eee;
}
a{
    color: #666;
}
.profile {
  display: flex;
  padding: 20px 10px;
  justify-content: space-between;
  align-items: center;
  border-bottom: 5px #ddd solid;

  img {
    width: (70 / 360) * 100vw;
    height: (70 / 360) * 100vw;
    border-radius: 50%;
  }

  .profile-center {
    flex: 1;
    padding: 0 10px;
  }

  .name {
    span {
      color: #75b9eb;
    }
  }

  .time {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
  }
}
</style>